﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace KaoQin.Common
{
    public static class ConfigHelper
    {
        /// <summary>
        /// 取得连接字符串
        /// </summary>
        public static string ConnString
        {
            get
            {
                //return DESEncrypt.Decrypt(ConfigurationManager.ConnectionStrings["default"].ConnectionString);
                //return ConfigurationManager.ConnectionStrings["default"].ConnectionString;
                return @"Data Source="+FileHelper.GetcurrPath()+"\\KaoQin.db;Password=123;";
                //return @"Data Source=E:\项目\考勤系统\代码\KaoQinSys\DB\KaoQin.db;Password=123;";
            }
        }


        public static string NewPassword
        {
            get
            {
                return "ABCDEF";
            }
        }

        public static string GetRFIDState(int state)
        {
            string flag = string.Empty;

            switch (state)
            { 
                case 0:
                    flag = "操作成功";
                    break;
                case 1:
                    flag = "0~2块都没读出来，可能刷卡太块";
                    break;
                case 2:
                    flag = "第0块已被读出，但1~2块读取失败";
                    break;
                case 3:
                    flag = "第0、1块已被读出，但2块读取失败";
                    break;
                case 8:
                    flag = "没有卡在感应区";
                    break;
                case 9:
                    flag = "有多张卡在感应区，寻卡过程中防冲突失败";
                    break;
                case 10:
                    flag = "该卡可能已被休眠，无法选中";
                    break;
                case 11:
                    flag = "密码装载失败";
                    break;
                case 12:
                    flag = "密码认证失败";
                    break;
                case 21:
                    flag = "本函数需要引用的动态库ICUSB.DLL不在当前目录下";
                    break;
                case 22:
                    flag = "动态库或驱动程序异常";
                    break;
                case 23:
                    flag = "没有找到读写设备";
                    break;
                case 24:
                    flag = "操作超时,可能是IC卡读写器有问题";
                    break;
                case 27:
                    flag = "USB传输不稳定导致传输的字符不全";
                    break;
                case 28:
                    flag = "USBUSB传输不稳定导致CRC校验错";
                    break;
                case -1:
                    flag = "密码长度不对";
                    break;
                case -2:
                    flag = "数据长度超出用户存储区容量";
                    break;
                case -3:
                    flag = "数据长度超出系统存储区容量";
                    break;
                case -4:
                    flag = "要写入的数据长度不能为零";
                    break;
                default:
                    flag = "RFID未知错误";
                    break;
            }


            return flag;
        }

        public static string GetSwipeState(string state)
        {
            string flag = string.Empty;

            switch (state)
            {
                case "0":
                    flag = "正常上班";
                    break;
                case "1":
                    flag = "上班迟到";
                    break;
                case "3":
                    flag = "下班早退";
                    break;
                case "2":
                    flag = "正常下班";
                    break;
                case "4":
                    flag = "非打卡时间";
                    break;
                case "5":
                    flag = "加班时间";
                    break;
                default :
                    flag = "未知";
                    break;
                
            }


            return flag;
        }

        public static string GetSexString(string val)
        {
            string flag = string.Empty;

            switch (val)
            {
                case "0":
                    flag = "女";
                    break;
                case "1":
                    flag = "男";
                    break;
                default:
                    flag = "未知";
                    break;

            }

            return flag;
        }

        public static string GetCardState(string val)
        {
            string flag = string.Empty;

            switch (val)
            {
                case "0":
                    flag = "正常";
                    break;
                case "1":
                    flag = "退卡";
                    break;
                 case "2":
                    flag = "挂失";
                    break;
                default:
                    flag = "未知";
                    break;

            }

            return flag;
        }


    }
}
